/*
be formed by using the elements of the array. 
eg: 10 9 
ans: 910 
2 3 5 78  
ans: 78532 
100 9 
ans: 9100
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

bool mycomp(int a, int b)
{
    ostringstream oss1, oss2;
    oss1 << a << b << endl;
    oss2 << b << a << endl;
    if (oss1.str() < oss2.str()) return true;
    else return false;
}

int getLargest(int A[], int size)
{
    vector<int> num(A, A + size);
    sort(num.begin(), num.end(), mycomp);
    for (int i = 0; i < size; i++)
        cout << num[i] << " ";
    ostringstream oss;

    for (int i = size-1; i >= 0; i--)
        oss << num[i];
    const char *s = oss.str().c_str();

    return atoi(s);
}

int main(int argc, char **argv)
{
    int A[] = {9,94,4,14,1};
    cout << getLargest(A, sizeof(A)/sizeof(int)) << endl;
}
